package org.iabako.shared.iservice.business;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import org.iabako.shared.entity.business.Expense;
import org.iabako.shared.entity.business.Installment;
import org.iabako.shared.iservice.generic.*;
import org.iabako.shared.querydefinition.dto.QueryDefinitionDTO;

import java.util.Date;
import java.util.List;

/**
 * Created by jose on 04/11/14.
 */
public interface ExpenseServiceAsync extends SearchServiceAsync, SuggestServiceAsync, CRUDServiceAsync, BusinessEntityServiceAsync, TaxServiceAsync {

    void getAllCustomCategories(AsyncCallback<List<String>> listIabakoAsyncCallback);

    void save(Expense expense, List<Installment> customInstallmentsDefinition, AsyncCallback<Expense> async);

    void getNewExpense(int index, Expense expenseReference, Date newDate, Double amount, AsyncCallback<Expense> async);

    void stopUndefinedExpensesCreation(Expense expense, AsyncCallback<Expense> iabakoAsyncCallback);

    void getTotal(QueryDefinitionDTO queryDefinitionDTO, AsyncCallback<Double> iabakoAsyncCallback);

    public static final class Util {
        private static ExpenseServiceAsync instance;

        public static final ExpenseServiceAsync getInstance() {
            if (instance == null) {
                instance = GWT.create(ExpenseService.class);
            }
            return instance;
        }
    }
}
